<?php

namespace app\crontab\task;

use app\common\model\ads\Ad as AdModel;

/**
 * 广告
 *
 * @icon fa fa-circle-o
 */
class Ad extends Common
{
    public function __construct(array $params = [])
    {
        parent::__construct($params);
    }

    /**
     * 定时处理广告的推荐、置顶状态
     */
    public function setstatus(){
        $res['norec'] = AdModel::where('recommendtime','<', time())->update([
            'isrec' => "0",
        ]);

        $res['notop'] = AdModel::where('toptime','<', time())->update([
            'istop' => "0",
        ]);

        $res['setrec'] = AdModel::where('recommendtime','>', time())->update([
            'isrec' => "1",
        ]);

        $res['settop'] = AdModel::where('toptime','>', time())->update([
            'istop' => "1",
        ]);

        return json_encode($res);
    }

}
